/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package boundRMLL73.impl;

import generalArchitecture.impl.ComputeBoxImpl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;

import technicRMLL73.TechnicRMLL73;
import technicRMLL73.impl.TechnicRMLL73Impl;
import utils.UtilsModelInstance;
import boundRMLL73.BoundRMLL73;
import boundRMLL73.BoundRMLL73Package;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Bound RMLL73</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link boundRMLL73.impl.BoundRMLL73Impl#getValue <em>Value</em>}</li>
 *   <li>{@link boundRMLL73.impl.BoundRMLL73Impl#getNb_Tasks <em>Nb Tasks</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class BoundRMLL73Impl extends ComputeBoxImpl implements BoundRMLL73 {
	/**
	 * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected static final double VALUE_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected double value = VALUE_EDEFAULT;

	/**
	 * The default value of the '{@link #getNb_Tasks() <em>Nb Tasks</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNb_Tasks()
	 * @generated
	 * @ordered
	 */
	protected static final int NB_TASKS_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getNb_Tasks() <em>Nb Tasks</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNb_Tasks()
	 * @generated
	 * @ordered
	 */
	protected int nb_Tasks = NB_TASKS_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BoundRMLL73Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BoundRMLL73Package.Literals.BOUND_RMLL73;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getValue() {
		return value;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValue(double newValue) {
		double oldValue = value;
		value = newValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BoundRMLL73Package.BOUND_RMLL73__VALUE, oldValue, value));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getNb_Tasks() {
		return nb_Tasks;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNb_Tasks(int newNb_Tasks) {
		int oldNb_Tasks = nb_Tasks;
		nb_Tasks = newNb_Tasks;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BoundRMLL73Package.BOUND_RMLL73__NB_TASKS, oldNb_Tasks, nb_Tasks));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public void compute() {

		/* Compute the bound*/
		this.value = this.nb_Tasks * (Math.pow(2, 1.0/this.nb_Tasks) - 1);

		/* Look for an instance of technicRMLL73 */
		TechnicRMLL73 t_rm = (TechnicRMLL73)UtilsModelInstance.lookForComputeBox(this, TechnicRMLL73Impl.class);
		
		/* Instance dosen't exits */
		if (t_rm == null) {
			
			/* Create Instance, add to general list, add to children list */
			t_rm = UtilsModelInstance.createTechnicRMLL73(this, null);
			
			/* Set Branch Graph*/
			UtilsModelInstance.linkComputeBox(this, t_rm, false);
				
		}
		/* Instance exists */
		else {
			
			/* Set Graph Branch */
			UtilsModelInstance.linkComputeBox(this, t_rm, true);
			
			/* Update attributes and compute */
			t_rm.setBoundLL73(this);
		}
		
		/**/
		t_rm.compute();

	}


	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BoundRMLL73Package.BOUND_RMLL73__VALUE:
				return new Double(getValue());
			case BoundRMLL73Package.BOUND_RMLL73__NB_TASKS:
				return new Integer(getNb_Tasks());
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BoundRMLL73Package.BOUND_RMLL73__VALUE:
				setValue(((Double)newValue).doubleValue());
				return;
			case BoundRMLL73Package.BOUND_RMLL73__NB_TASKS:
				setNb_Tasks(((Integer)newValue).intValue());
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BoundRMLL73Package.BOUND_RMLL73__VALUE:
				setValue(VALUE_EDEFAULT);
				return;
			case BoundRMLL73Package.BOUND_RMLL73__NB_TASKS:
				setNb_Tasks(NB_TASKS_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BoundRMLL73Package.BOUND_RMLL73__VALUE:
				return value != VALUE_EDEFAULT;
			case BoundRMLL73Package.BOUND_RMLL73__NB_TASKS:
				return nb_Tasks != NB_TASKS_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (value: ");
		result.append(value);
		result.append(", nb_Tasks: ");
		result.append(nb_Tasks);
		result.append(')');
		return result.toString();
	}

} //BoundRMLL73Impl
